package com.sz.mes.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.diboot.core.util.BeanUtils;
import com.sz.mes.entity.ProductPlan;
import com.sz.mes.mapper.ProductPlanMapper;
import com.sz.mes.service.ProductPlanService;
import com.sz.mes.vo.ProductPlanDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import java.io.Serializable;

/**
* 生产计划相关Service实现
* @author hem
* @version 1.0
* @date 2023-05-25
 * Copyright © szhs
*/
@Service
@Slf4j
public class ProductProductPlanServiceImpl extends BaseCustomServiceImpl<ProductPlanMapper, ProductPlan> implements ProductPlanService {

    @Override
    public List<ProductPlanDetailVO> getPlanTree(Serializable rootId) {
        LambdaQueryWrapper<ProductPlan> queryWrapper = new LambdaQueryWrapper<ProductPlan>();
        queryWrapper.orderByAsc(ProductPlan::getId);
        List<ProductPlan> productPlanList = getEntityList(queryWrapper);
        List<ProductPlanDetailVO> planDetailVOList = BeanUtils.convertList(productPlanList, ProductPlanDetailVO.class);
        return BeanUtils.buildTree(planDetailVOList, rootId);
    }

}
